home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2005 March
/
CMCD0305.ISO
/
Software
/
Shareware
/
Utilitare
/
emu
/
Emu8086_Setup_307c.exe
/
{app}
/
Samples
/
paramexe.asm
< prev
next >
Wrap
Assembly Source File
|
2002-08-23
|
2KB
|
93 lines
; This sample prints out the command
; line parameters.
; In DOS you simply add this line
; after an executable:
; paramexe.exe my parameters
; In emulator you should set them by
; selecting "Set command line parameters"
; from "File" menu of emulator window.
; Directive to select
; "make EXE" by default when
; source file is compiled:
#MAKE_EXE#
DSEG SEGMENT 'DATA'
buffer DB 100 dup (' ')
msg DB 'No command line parameters!', 13, 10, '$'
DSEG ENDS
SSEG SEGMENT STACK 'STACK'
DW 100h DUP(?)
SSEG ENDS
CSEG SEGMENT 'CODE'
;*******************************************
START PROC FAR
; set segment registers:
MOV AX, DSEG
MOV DS, AX
; we'll keep PSP address in ES,
; so ES is not set to data segment.
; address of command line:
MOV SI, 80h
; copy command line to our buffer:
XOR CX, CX ; zero CX register.
MOV CL, ES:[SI] ; get command line size.
LEA DI, buffer ; load buffer address to DI.
CMP CX, 0 ; CX = 0 ?
JZ no_param ; then skip the copy.
INC SI ; copy from second byte.
next_char:
MOV AL, ES:[SI]
MOV [DI], AL
INC SI
INC DI
LOOP next_char
copied:
; set '$' sign in the end of the buffer:
MOV BYTE PTR [DI], '$'
; print out the buffer:
LEA DX, buffer
MOV AH, 9h
INT 21h
JMP exit ; skip error message.
no_param:
; print out the error message:
LEA DX, msg
MOV AH, 09h
INT 21h
JMP exit
; exit here:
exit:
; return to operating system:
MOV AH, 4Ch
INT 21h
RET
START ENDP
;*******************************************
CSEG ENDS
END START